
import java.util.Collection;

import org.jivesoftware.smack.Connection;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.filter.PacketTypeFilter;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.PacketExtension;


/**
 * 
 * This manager adds a packet listener to the connection.
 * @author Peter
 * 
 */
public class MyExtensionManager {


	Connection mConnection = null;

	public MyExtensionManager(Connection connection){
		mConnection = connection;
		init();
	}

	private void init(){
		
		PacketListener packetListener = new PacketListener() {
			public void processPacket(Packet packet) {
				//cast the packet to our class
				MyIQPacket ep = (MyIQPacket) packet;
				System.out.println("capability: "+ep.getCapability());
				System.out.println("value: "+ep.getValue());
			}
		};
		
		if(mConnection!=null) {
			//create a packet filter to get only relevant packets
			PacketFilter packetFilter = new PacketTypeFilter(MyIQPacket.class);
			//add the packet listener
			mConnection.addPacketListener(packetListener, packetFilter);
		}
	}
}
